package com.atguigu.oss.service.controller;

import com.atguigu.commonutils.R;
import com.atguigu.oss.service.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: Cyrus
 * @CreateDate: 2020/12/7
 */
@Api(description = "对象存储OSS")
@RestController
@RequestMapping("/eduoss/fileoss")
public class OssController {
    @Autowired
    private OssService ossService;

    @ApiOperation(value = "对象存储OSS文件上传")
    //上传头像
    @PostMapping("/uploadAvatar")
    public R uploadOssFile(MultipartFile file) {
        //获取上传文件，用MultipartFile格式接收
        //返回上传的oss路径
        String url = ossService.uploadFileAvatar(file);

        return R.ok().data("url",url);
    }
}
